package kn.webstd.g4g.commons.dts;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;

import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;

public class Email {

private Integer id;
	
	private Collection<InternetAddress> para;	
	private Collection<InternetAddress> cc;
	private Collection<InternetAddress> cco;
	private String asunto;
	private Collection<File> adjuntos;
	private Map<String, String> variables;	
	private String contenido;
	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}

	public Collection<File> getAdjuntos() {
        return adjuntos;
    }

        public void addAdjunto(File adjunto) {
        if (this.adjuntos == null) {
            this.adjuntos = new ArrayList<File>();
        }
        this.adjuntos.add(adjunto);
    }

    public void addAdjunto(String adjunto) {
        if (this.adjuntos == null) {
            this.adjuntos = new ArrayList<File>();
        }
        this.adjuntos.add(new File(adjunto));
    }

    public String getAsunto() {
        return asunto;
    }

    public void setAsunto(String asunto) {
        this.asunto = asunto;
    }

    public Collection<InternetAddress> getCc() {
        return cc;
    }

    public void addCc(InternetAddress cc) {
        if (this.cc == null) {
            this.cc = new ArrayList<InternetAddress>();
        }
        this.cc.add(cc);
    }

    public Collection<InternetAddress> getCco() {
        return cco;
    }

    public void addCco(InternetAddress cco) {
        if (this.cco == null) {
            this.cco = new ArrayList<InternetAddress>();
        }
        this.cco.add(cco);
    }

    public String getContenido() {
        return contenido;
    }

    public void setContenido(String contenido) {
        this.contenido = contenido;
    }

    public Collection<InternetAddress> getPara() {
        return para;
    }

    public void addPara(InternetAddress para) {
        if (this.para == null) {
            this.para = new ArrayList<InternetAddress>();
        }
        this.para.add(para);
    }
    
    public void setVariables(Map<String, String> variables) {
		this.variables = variables;
	}
    
    public Map<String, String> getVariables() {
		return variables;
	}

	public void addPara(String para) {
		try {
			this.addPara(new InternetAddress(para));
		} catch (AddressException ex) {
			throw new g4gException("Email Address not valid: " + para, ex);
		}
		
	}
	
	public void addCco(String cco) {
		try {
			this.addCco(new InternetAddress(cco));
		} catch (AddressException ex) {
			throw new g4gException("Email Address not valid: " + cco, ex);
		}
		
	}
	
	public void addCc(String cco) {
		try {
			this.addCc(new InternetAddress(cco));
		} catch (AddressException ex) {
			throw new g4gException("Email Address not valid: " + cco, ex);
		}
		
	}
}
